﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using SpaceGame.Player;
using Microsoft.Xna.Framework.Graphics;
using SpaceGame.Managers;

namespace SpaceGame.HUD
{
    public class Rights : DrawableGameComponent
    {
        private SpriteBatch m_SpriteBatch;
        private Texture2D m_RightTexture;
        private Vector2 m_Size = new Vector2(30f, 30f);
        private PlayerShip m_Player;

        public Rights(Game game, PlayerShip player) : base(game)
        {
            m_SpriteBatch = new SpriteBatch(game.GraphicsDevice);
            m_Player = player;
        }

        protected override void LoadContent()
        {
            m_RightTexture = Game.Content.Load<Texture2D>("Textures/Player/ship");
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            if (GameStateManager.GameState != GameState.Playing)
                return;

            float drawX = 0;
            m_SpriteBatch.Begin();
            for (int i = 0; i < m_Player.Rights; i++)
            {
                drawX += m_Size.X + 5;
                m_SpriteBatch.Draw(m_RightTexture, new Rectangle((int)drawX, 15, (int)m_Size.X, (int)m_Size.Y), null, Color.White, MathHelper.ToRadians(90f),
                    new Vector2(m_Size.X / 2, m_Size.Y / 2), SpriteEffects.None, 1f);
            }
            m_SpriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
